package simpledateformat;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class SimpleDateFormatDemo {
    public static void main(String[] args) throws ParseException {
        //简单日期格式化的类
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        //格式化 : Date---->String
        Date now = new Date();//现在

        System.out.println("now = " + now);
        //格式化日期
        String format = sdf.format(now);
        System.out.println("format = " + format);
        System.out.println("===========");


        //解析 : String  -- > Date

        String strDate ="1990-01-01 08:08:08";

        Date birthDate = sdf.parse(strDate);
        System.out.println("birthDate = " + birthDate);

    }
}
